Take-home Exercise 4-2

Decoding Chaos: Geospatial Data Exploratory Analysis (GDEA)

Author

Teo Suan Ern

Published

February 27, 2024

Modified

February 29, 2024

1. Overview

Note: This is a continuation of the take-home exercise 4. For Project Brief, Project Objective, Storyboard and Initial Exploratory Data Analysis, please view it under Initial Data Exploratory Analysis segment.

1.1 Exploratory Data Analysis

This project is separated into two segments:

  1. Initial Data Exploratory Analysis (IDEA) – Click here for IDEA page
  2. Geospatial Data Exploratory Analysis (GDEA) – Current Page

2. Geospatial Data Preparation

2.1 Install and launch R packages

The project uses p_load() of pacman package to check if the R packages are installed in the computer.

The following code chunk is used to install and launch the R packages.

Show code
pacman::p_load(tidyverse, kableExtra,
               leaflet, rmarkdown, knitr,
               highcharter, # timeseries highchart
               viridis, ggthemes,
               ggplot2, tidyr, dplyr, viridisLite, RColorBrewer,  
               countrycode, sf, spdep, tmap, leaflet, # geospatial
               leaflet.extras, magrittr, mapview, leafsync, # hotspot
               tm, plotly)

2.2 Import Aspatial Data

final <- readRDS("data/final.rds")
  • coords argument requires you to provide the column name of the x-coordinates first then followed by the column name of the y-coordinates.

  • crs argument requires you to provide the coordinates system in epsg format.

  • EPSG:4979 is WGS 84 Geographic Coordinate system and EPSG:4144 is Myanmar Projected Coordinate System.

Use st_as_sf() from sf package to convert listing data frame into simple feature data frame.

data_sf <- st_as_sf(final, 
                  coords = c("longitude", "latitude"),
                  crs=4979) %>%
  st_transform(crs = 4144)
write_rds(data_sf, 
          "data/myan.rds")
glimpse(data_sf)
Rows: 13,177
Columns: 29
$ event_id_cnty        <chr> "MMR56370", "MMR56871", "MMR56878", "MMR56900", "…
$ event_date           <date> 2023-12-31, 2023-12-31, 2023-12-31, 2023-12-31, …
$ year                 <int> 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2023, 2…
$ disorder_type        <chr> "Political violence", "Political violence", "Poli…
$ event_type           <chr> "Battles", "Battles", "Explosions/Remote violence…
$ sub_event_type       <chr> "Armed clash", "Armed clash", "Air/drone strike",…
$ actor1               <chr> "Phoenix DF: Phoenix Defense Force (Nattalin)", "…
$ inter1               <int> 3, 3, 1, 3, 3, 1, 3, 1, 2, 3, 1, 2, 3, 2, 1, 1, 3…
$ actor2               <chr> "Military Forces of Myanmar (2021-)", "Military F…
$ inter2               <int> 1, 1, 7, 1, 1, 7, 1, 7, 1, 1, 3, 1, 1, 1, 7, 7, 3…
$ interaction          <int> 13, 13, 17, 13, 13, 17, 13, 17, 12, 13, 13, 12, 1…
$ civilian_targeting   <chr> "", "", "Civilian targeting", "", "", "Civilian t…
$ iso                  <int> 104, 104, 104, 104, 104, 104, 104, 104, 104, 104,…
$ region               <chr> "Southeast Asia", "Southeast Asia", "Southeast As…
$ country              <chr> "Myanmar", "Myanmar", "Myanmar", "Myanmar", "Myan…
$ admin1               <chr> "Bago-West", "Mon", "Sagaing", "Sagaing", "Mandal…
$ admin2               <chr> "Thayarwady", "Mawlamyine", "Katha", "Monywa", "M…
$ admin3               <chr> "Nattalin", "Ye", "Tigyaing", "Chaung-U", "Taungt…
$ location             <chr> "Kyauk Pyoke", "Kyaung Ywar", "Kan Pauk", "Chaung…
$ source               <chr> "Khit Thit Media; Myanmar Pressphoto Agency", "De…
$ notes                <chr> "On 31 December 2023, near Kyauk Pyoke village (N…
$ fatalities           <int> 4, 3, 1, 1, 2, 1, 3, 1, 1, 4, 2, 4, 2, 1, 1, 7, 3…
$ total_fata           <int> 15716, 15716, 15716, 15716, 15716, 15716, 15716, …
$ total_inci           <int> 4054, 4054, 4054, 4054, 4054, 4054, 4054, 4054, 4…
$ political_rate       <dbl> 99.46, 99.46, 99.46, 99.46, 99.46, 99.46, 99.46, …
$ civilian_rate        <dbl> 23.33, 23.33, 23.33, 23.33, 23.33, 23.33, 23.33, …
$ non_state_exchange   <dbl> 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0.02, 0…
$ govt_regain_exchange <dbl> 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0…
$ geometry             <POINT [°]> POINT (95.8295 18.6245), POINT (97.98861 15…

Use st_transform() to re-project armed conflict incident points from one coordinate system to another coordinate system mathematically.

data_sf4144 <- st_transform(data_sf, 4144)
st_crs(data_sf4144)
Coordinate Reference System:
  User input: EPSG:4144 
  wkt:
GEOGCRS["Kalianpur 1937",
    DATUM["Kalianpur 1937",
        ELLIPSOID["Everest 1830 (1937 Adjustment)",6377276.345,300.8017,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Geodesy."],
        AREA["Bangladesh - onshore; India - mainland onshore; Myanmar - onshore and Moattama area offshore; Pakistan - onshore."],
        BBOX[8.02,60.86,37.07,101.17]],
    ID["EPSG",4144]]

2.3 Import Geospatial Data

Myanmar Level-3 Administrative Boundary (also known as Local Government Area, LGA) polygon features GIS data was downloaded from geoBoundaries.

Use st_read to read geospatial layers. Use st_union to combine three

# myan_bound_adm1 <- st_read(dsn="data", layer="geoBoundaries-MMR-ADM1")

myan_bound_adm2 <- st_read(dsn="data",
               layer="geoBoundaries-MMR-ADM2")
Reading layer `geoBoundaries-MMR-ADM2' from data source 
  `C:\teoose\ISSS608\Take-home_Ex\Take-home_Ex04\data' using driver `ESRI Shapefile'
Simple feature collection with 74 features and 5 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: 92.17275 ymin: 9.671252 xmax: 101.1699 ymax: 28.54554
Geodetic CRS:  WGS 84
# myan_bound_adm3 <- st_read(dsn="data", layer="geoBoundaries-MMR-ADM3")
myan_bound <- myan_bound_adm2
glimpse(myan_bound)
Rows: 74
Columns: 6
$ shapeName  <chr> "Hinthada", "Labutta", "Maubin", "Myaungmya", "Pathein", "P…
$ shapeISO   <chr> NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,…
$ shapeID    <chr> "60261553B48695999525720", "60261553B3473904040713", "60261…
$ shapeGroup <chr> "MMR", "MMR", "MMR", "MMR", "MMR", "MMR", "MMR", "MMR", "MM…
$ shapeType  <chr> "ADM2", "ADM2", "ADM2", "ADM2", "ADM2", "ADM2", "ADM2", "AD…
$ geometry   <MULTIPOLYGON [°]> MULTIPOLYGON (((95.2637 18...., MULTIPOLYGON (…
write_rds(myan_bound, 
          "data/pt_myan.rds")

Use st_crs() to check the set coordinate system of myan_bound.

st_crs(myan_bound)
Coordinate Reference System:
  User input: WGS 84 
  wkt:
GEOGCRS["WGS 84",
    ENSEMBLE["World Geodetic System 1984 ensemble",
        MEMBER["World Geodetic System 1984 (Transit)"],
        MEMBER["World Geodetic System 1984 (G730)"],
        MEMBER["World Geodetic System 1984 (G873)"],
        MEMBER["World Geodetic System 1984 (G1150)"],
        MEMBER["World Geodetic System 1984 (G1674)"],
        MEMBER["World Geodetic System 1984 (G1762)"],
        MEMBER["World Geodetic System 1984 (G2139)"],
        ELLIPSOID["WGS 84",6378137,298.257223563,
            LENGTHUNIT["metre",1]],
        ENSEMBLEACCURACY[2.0]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Horizontal component of 3D system."],
        AREA["World."],
        BBOX[-90,-180,90,180]],
    ID["EPSG",4326]]

Use st_transform() to assign correct EPSG code to dataframe, from one coordinate system to another coordinate system mathematically.

myan_bound4144 <- st_transform(myan_bound, 4144)
st_crs(myan_bound4144)
Coordinate Reference System:
  User input: EPSG:4144 
  wkt:
GEOGCRS["Kalianpur 1937",
    DATUM["Kalianpur 1937",
        ELLIPSOID["Everest 1830 (1937 Adjustment)",6377276.345,300.8017,
            LENGTHUNIT["metre",1]]],
    PRIMEM["Greenwich",0,
        ANGLEUNIT["degree",0.0174532925199433]],
    CS[ellipsoidal,2],
        AXIS["geodetic latitude (Lat)",north,
            ORDER[1],
            ANGLEUNIT["degree",0.0174532925199433]],
        AXIS["geodetic longitude (Lon)",east,
            ORDER[2],
            ANGLEUNIT["degree",0.0174532925199433]],
    USAGE[
        SCOPE["Geodesy."],
        AREA["Bangladesh - onshore; India - mainland onshore; Myanmar - onshore and Moattama area offshore; Pakistan - onshore."],
        BBOX[8.02,60.86,37.07,101.17]],
    ID["EPSG",4144]]

Use st_join to create new variable (based on year) Use tapply to

To find out the number of fatalities and armed conflict incidents in each third-level administrative region.

We will extract the fatalities records by event_type field.

for (year in 2010:2023) {
  # Filter data_sf4144 for the current year
  data_sf4144_year <- data_sf4144[data_sf4144$year == year, ]
  
  # Perform spatial join
  joined_data <- st_join(myan_bound4144, data_sf4144_year)
  
  ##############
  # Summarise total fatalities at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no fatalities
  total_fata_col <- paste0('total_fata_', year)
  myan_bound4144[[total_fata_col]] <- tapply(joined_data$fatalities, joined_data$shapeID, sum)
  myan_bound4144[[total_fata_col]][is.na(myan_bound4144[[total_fata_col]])] <- 0

  # Summarise percentage of fatalities at each adm2 level in myan_bound4144
  pct_fata_col <- paste0('pct_fata_', year)
  myan_bound4144[[pct_fata_col]] <- round(myan_bound4144[[total_fata_col]] / sum(myan_bound4144[[total_fata_col]]) * 100, 2)
  myan_bound4144[[pct_fata_col]][is.na(myan_bound4144[[pct_fata_col]])] <- 0
  
  
  ##############  
  # Summarise total incidents at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no incidents
  total_inci_col <- paste0('total_inci_', year)
  myan_bound4144[[total_inci_col]] <- tapply(joined_data$year, joined_data$shapeID, sum)
  myan_bound4144[[total_inci_col]][is.na(myan_bound4144[[total_inci_col]])] <- 0
  
  # Summarise percentage of incidents at each adm2 level in myan_bound4144
  pct_inci_col <- paste0('pct_fata_', year)
  myan_bound4144[[pct_inci_col]] <- round(myan_bound4144[[total_inci_col]] / sum(myan_bound4144[[total_inci_col]]) * 100, 2)
  myan_bound4144[[pct_inci_col]][is.na(myan_bound4144[[pct_inci_col]])] <- 0
  
  ##############  
  # Summarise total political violence rate at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no incidents
  total_politicalrate_col <- paste0('total_politicalrate_', year)
  myan_bound4144[[total_politicalrate_col]] <- tapply(joined_data$political_rate, joined_data$shapeID, sum)
  myan_bound4144[[total_politicalrate_col]][is.na(myan_bound4144[[total_politicalrate_col]])] <- 0
  
  # Summarise percentage of political violence rate at each adm2 level in myan_bound4144
  pct_politicalrate_col <- paste0('pct_politicalrate_', year)
  myan_bound4144[[pct_politicalrate_col]] <- 
    round(myan_bound4144[[total_politicalrate_col]] / sum(myan_bound4144[[total_inci_col]]) * 100, 2)
  myan_bound4144[[pct_politicalrate_col]][is.na(myan_bound4144[[pct_politicalrate_col]])] <- 0
  
  ##############  
  # Summarise total civilian violence rate at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no incidents
  total_civilianrate_col <- paste0('total_civilianrate_', year)
  myan_bound4144[[total_civilianrate_col]] <- tapply(joined_data$civilian_rate, joined_data$shapeID, sum)
  myan_bound4144[[total_civilianrate_col]][is.na(myan_bound4144[[total_civilianrate_col]])] <- 0
  
  # Summarise percentage of civilian violence rate at each adm2 level in myan_bound4144
  pct_civilianrate_col <- paste0('pct_civilianrate_', year)
  myan_bound4144[[pct_civilianrate_col]] <- 
  round(myan_bound4144[[total_civilianrate_col]] / sum(myan_bound4144[[total_inci_col]]) * 100, 2)
  myan_bound4144[[pct_civilianrate_col]][is.na(myan_bound4144[[pct_civilianrate_col]])] <- 0
  
  
  ##############  
  # Summarise non-state ex rate at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no incidents
  total_nonstateex_col <- paste0('total_nonstateex_', year)
  myan_bound4144[[total_nonstateex_col]] <- tapply(joined_data$non_state_exchange, joined_data$shapeID, sum)
  myan_bound4144[[total_nonstateex_col]][is.na(myan_bound4144[[total_civilianrate_col]])] <- 0
  
  # Summarise percentage of non-state ex rate at each adm2 level in myan_bound4144
  pct_nonstateex_col <- paste0('pct_nonstateex_', year)
  myan_bound4144[[pct_nonstateex_col]] <- 
  round(myan_bound4144[[total_nonstateex_col]] / sum(myan_bound4144[[total_inci_col]]) * 1000)
  myan_bound4144[[pct_nonstateex_col]][is.na(myan_bound4144[[pct_nonstateex_col]])] <- 0
  
  
  ##############  
  # Summarise govt regain rate at each adm2 level in myan_bound4144
  # Replace NA with 0 for polygons with no incidents
  total_govtregain_col <- paste0('total_govtregain_', year)
  myan_bound4144[[total_govtregain_col]] <- tapply(joined_data$govt_regain_exchange, joined_data$shapeID, sum)
  myan_bound4144[[total_govtregain_col]][is.na(myan_bound4144[[total_govtregain_col]])] <- 0
  
  # Summarise percentage of govt regain rate at each adm2 level in myan_bound4144
  pct_govtregain_col <- paste0('pct_govtregain_', year)
  myan_bound4144[[pct_govtregain_col]] <- 
  round(myan_bound4144[[total_govtregain_col]] / sum(myan_bound4144[[total_inci_col]]) * 1000)
  myan_bound4144[[pct_govtregain_col]][is.na(myan_bound4144[[pct_govtregain_col]])] <- 0
  
  
  ############## 
  # Summarise by event_type at each adm2 level in myan_bound4144
  event_types <- unique(data_sf4144$event_type)
  for (event_type in event_types) {
    event_count_col <- paste0(event_type, '_', year)
    myan_bound4144[[event_count_col]] <- tapply(joined_data$event_type == event_type, joined_data$shapeID, sum)
    myan_bound4144[[event_count_col]][is.na(myan_bound4144[[event_count_col]])] <- 0
  }
}

Remove duplicated rows

# remove duplicated rows
duplicate_rows <- duplicated(myan_bound4144)

myan_bound4144 <- myan_bound4144[!duplicate_rows, ]

Use st_intersect() to identify armed conflicts located inside each administrative region.

myan_bound4144$total_inci <- 
  lengths(st_intersects(myan_bound4144, data_sf4144))

Calculate total fatalities in each administrative region.

myan_bound4144$total_fata <- 
  tapply(joined_data$fatalities, joined_data$shapeID, sum)
summary(myan_bound4144$total_inci)
   Min. 1st Qu.  Median    Mean 3rd Qu.    Max. 
    0.0    42.0   113.5   178.0   281.8   845.0 

Use top_n() to list the second third-level administrative region of incident counts.

top_n(myan_bound4144, 1, total_inci) %>% 
  kable()
shapeName shapeISO shapeID shapeGroup shapeType geometry total_fata_2010 pct_fata_2010 total_inci_2010 total_politicalrate_2010 pct_politicalrate_2010 total_civilianrate_2010 pct_civilianrate_2010 total_nonstateex_2010 pct_nonstateex_2010 total_govtregain_2010 pct_govtregain_2010 Battles_2010 Explosions/Remote violence_2010 Violence against civilians_2010 Protests_2010 Strategic developments_2010 Riots_2010 total_fata_2011 pct_fata_2011 total_inci_2011 total_politicalrate_2011 pct_politicalrate_2011 total_civilianrate_2011 pct_civilianrate_2011 total_nonstateex_2011 pct_nonstateex_2011 total_govtregain_2011 pct_govtregain_2011 Battles_2011 Explosions/Remote violence_2011 Violence against civilians_2011 Protests_2011 Strategic developments_2011 Riots_2011 total_fata_2012 pct_fata_2012 total_inci_2012 total_politicalrate_2012 pct_politicalrate_2012 total_civilianrate_2012 pct_civilianrate_2012 total_nonstateex_2012 pct_nonstateex_2012 total_govtregain_2012 pct_govtregain_2012 Battles_2012 Explosions/Remote violence_2012 Violence against civilians_2012 Protests_2012 Strategic developments_2012 Riots_2012 total_fata_2013 pct_fata_2013 total_inci_2013 total_politicalrate_2013 pct_politicalrate_2013 total_civilianrate_2013 pct_civilianrate_2013 total_nonstateex_2013 pct_nonstateex_2013 total_govtregain_2013 pct_govtregain_2013 Battles_2013 Explosions/Remote violence_2013 Violence against civilians_2013 Protests_2013 Strategic developments_2013 Riots_2013 total_fata_2014 pct_fata_2014 total_inci_2014 total_politicalrate_2014 pct_politicalrate_2014 total_civilianrate_2014 pct_civilianrate_2014 total_nonstateex_2014 pct_nonstateex_2014 total_govtregain_2014 pct_govtregain_2014 Battles_2014 Explosions/Remote violence_2014 Violence against civilians_2014 Protests_2014 Strategic developments_2014 Riots_2014 total_fata_2015 pct_fata_2015 total_inci_2015 total_politicalrate_2015 pct_politicalrate_2015 total_civilianrate_2015 pct_civilianrate_2015 total_nonstateex_2015 pct_nonstateex_2015 total_govtregain_2015 pct_govtregain_2015 Battles_2015 Explosions/Remote violence_2015 Violence against civilians_2015 Protests_2015 Strategic developments_2015 Riots_2015 total_fata_2016 pct_fata_2016 total_inci_2016 total_politicalrate_2016 pct_politicalrate_2016 total_civilianrate_2016 pct_civilianrate_2016 total_nonstateex_2016 pct_nonstateex_2016 total_govtregain_2016 pct_govtregain_2016 Battles_2016 Explosions/Remote violence_2016 Violence against civilians_2016 Protests_2016 Strategic developments_2016 Riots_2016 total_fata_2017 pct_fata_2017 total_inci_2017 total_politicalrate_2017 pct_politicalrate_2017 total_civilianrate_2017 pct_civilianrate_2017 total_nonstateex_2017 pct_nonstateex_2017 total_govtregain_2017 pct_govtregain_2017 Battles_2017 Explosions/Remote violence_2017 Violence against civilians_2017 Protests_2017 Strategic developments_2017 Riots_2017 total_fata_2018 pct_fata_2018 total_inci_2018 total_politicalrate_2018 pct_politicalrate_2018 total_civilianrate_2018 pct_civilianrate_2018 total_nonstateex_2018 pct_nonstateex_2018 total_govtregain_2018 pct_govtregain_2018 Battles_2018 Explosions/Remote violence_2018 Violence against civilians_2018 Protests_2018 Strategic developments_2018 Riots_2018 total_fata_2019 pct_fata_2019 total_inci_2019 total_politicalrate_2019 pct_politicalrate_2019 total_civilianrate_2019 pct_civilianrate_2019 total_nonstateex_2019 pct_nonstateex_2019 total_govtregain_2019 pct_govtregain_2019 Battles_2019 Explosions/Remote violence_2019 Violence against civilians_2019 Protests_2019 Strategic developments_2019 Riots_2019 total_fata_2020 pct_fata_2020 total_inci_2020 total_politicalrate_2020 pct_politicalrate_2020 total_civilianrate_2020 pct_civilianrate_2020 total_nonstateex_2020 pct_nonstateex_2020 total_govtregain_2020 pct_govtregain_2020 Battles_2020 Explosions/Remote violence_2020 Violence against civilians_2020 Protests_2020 Strategic developments_2020 Riots_2020 total_fata_2021 pct_fata_2021 total_inci_2021 total_politicalrate_2021 pct_politicalrate_2021 total_civilianrate_2021 pct_civilianrate_2021 total_nonstateex_2021 pct_nonstateex_2021 total_govtregain_2021 pct_govtregain_2021 Battles_2021 Explosions/Remote violence_2021 Violence against civilians_2021 Protests_2021 Strategic developments_2021 Riots_2021 total_fata_2022 pct_fata_2022 total_inci_2022 total_politicalrate_2022 pct_politicalrate_2022 total_civilianrate_2022 pct_civilianrate_2022 total_nonstateex_2022 pct_nonstateex_2022 total_govtregain_2022 pct_govtregain_2022 Battles_2022 Explosions/Remote violence_2022 Violence against civilians_2022 Protests_2022 Strategic developments_2022 Riots_2022 total_fata_2023 pct_fata_2023 total_inci_2023 total_politicalrate_2023 pct_politicalrate_2023 total_civilianrate_2023 pct_civilianrate_2023 total_nonstateex_2023 pct_nonstateex_2023 total_govtregain_2023 pct_govtregain_2023 Battles_2023 Explosions/Remote violence_2023 Violence against civilians_2023 Protests_2023 Strategic developments_2023 Riots_2023 total_inci total_fata
Shwebo NA 60261553B74508542584232 MMR ADM2 MULTIPOLYGON (((95.96527 22... 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 NA 0 0 0 0 0 0 0 0 0 51 0.72 40420 1963 0.04 832.4 0.01 0.8 0 0 0 5 7 7 1 0 0 77 0.54 48528 2384.4 0.03 632.64 0.01 6 0 2.4 0 9 4 11 0 0 0 14 0.27 22253 1094.06 0.01 256.63 0 0.22 0 0 0 1 1 9 0 0 0 845 14

Use st_area() to derive the area of each second-level administrative region.

myan_bound4144$Area <- myan_bound4144 %>%
  st_area()

Use code chunk below to compute density area.

mapping_rates <- myan_bound4144 %>%
  mutate(# density rates
         inci_density = as.numeric(`total_inci`/Area * 1000000),
         fata_density = as.numeric(`total_fata`/Area * 1000000)) %>%
  replace_na(list(inci_density = 0, fata_density = 0, total_fata = 0, total_inci = 0)) %>%
  select(shapeName, shapeID, shapeGroup, shapeType, geometry, total_inci, inci_density,
         total_fata, fata_density, starts_with("pct"))
tmap_mode("plot")

https://spatialanalysis.github.io/lab_tutorials/4_R_Mapping.html

3. Geospatial Exploratory Data Analysis

3.1 Spatial Statistical Distribution

Design Features - XXX
  • t

Use Box map

Create boxbreak functions

The code chunk below is an R function that creating break points for a box map.

arguments: v: vector with observations mult: multiplier for IQR (default 1.5) returns: bb: vector with 7 break points compute quartile and fences

boxbreaks <- function(v,mult=1.5) {
  qv <- unname(quantile(v))
  iqr <- qv[4] - qv[2]
  upfence <- qv[4] + mult * iqr
  lofence <- qv[2] - mult * iqr
  # initialize break points vector
  bb <- vector(mode="numeric",length=7)
  # logic for lower and upper fences
  if (lofence < qv[1]) {  # no lower outliers
    bb[1] <- lofence
    bb[2] <- floor(qv[1])
  } else {
    bb[2] <- lofence
    bb[1] <- qv[1]
  }
  if (upfence > qv[5]) { # no upper outliers
    bb[7] <- upfence
    bb[6] <- ceiling(qv[5])
  } else {
    bb[6] <- upfence
    bb[7] <- qv[5]
  }
  bb[3:5] <- qv[2:4]
  return(bb)
}

Creating the get.var function The code chunk below is an R function to extract a variable as a vector out of an sf data frame.

arguments: vname: variable name (as character, in quotes) df: name of sf data frame returns: v: vector with values (without a column name)

get.var <- function(vname,df) {
  v <- df[vname] %>% st_set_geometry(NULL)
  v <- unname(v[,1])
  return(v)
}

Boxmap function The code chunk below is an R function to create a box map. arguments:

vnam: variable name (as character, in quotes)

df: simple features polygon layer

legtitle: legend title

mtitle: map title

mult: multiplier for IQR

returns: a tmap-element (plots a map)

boxmap <- function(vnam, df, 
                   legtitle=NA,
                   mtitle= paste0("Box Map of ", vnam),
                   mult=1.5){
  var <- get.var(vnam,df)
  bb <- boxbreaks(var)
  tm_shape(df) +
    tm_polygons() +
  tm_shape(df) +
     tm_fill(vnam,title=legtitle,
             breaks=bb,
             palette="Reds",
          labels = c("lower outlier", 
                     "< 25%", 
                     "25% - 50%", 
                     "50% - 75%",
                     "> 75%", 
                     "upper outlier"))  +
  tm_borders() +
  tm_layout(main.title = mtitle, 
            title.position = c("left",
                               "top"))
}
box_inci <- boxmap("total_inci", mapping_rates)

box_fata <- boxmap("total_fata", mapping_rates)
tmap_arrange(box_fata, box_inci, asp=1, ncol=2)

3.2 Spatial Area Density

Design Features - XXX
  • t

Density map

Visualising Spatial Density of Armed Conflicts

To visualise spatial density (concentration) within the different geographical subnational administrative regions.

kmeans Classification

Show code
inci_den <- tm_shape(mapping_rates) +
  tm_fill("inci_density",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Density of Armed Conflicts in Myanmar \n(kmeans Classification)",
            title = "",
            main.title.size = 1,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

fata_den <- tm_shape(mapping_rates) +
  tm_fill("fata_density",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Density of Fatalities in Myanmar \n(kmeans Classification)",
            title = "",
            main.title.size = 1,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))
Show code
tmap_arrange(inci_den, fata_den,
             asp = 1,
             ncol=2, nrow=1)

3.3 Spatial Distribution

Choropleth Map ::: {.callout-note icon=“false”} ### Design Features - XXX

  • t :::

Visualising Spatial Distribution of Armed Conflicts

To visualise spatial pattern or distribution across different geographical subnational administrative regions.

Distribution of Armed Conflict (by classifications)

Show code
class_equal <- tm_shape(mapping_rates) +
  tm_fill("total_inci",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Distribution of Armed Conflicts in Myanmar \nEqual classification",
            title = "(2010-2023)",
            main.title.size = 0.7,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


class_pretty <- tm_shape(mapping_rates) +
  tm_fill("total_inci",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Distribution of Armed Conflicts in Myanmar \nPretty classification",
            title = "(2010-2023)",
            main.title.size = 0.7,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

class_quant <- tm_shape(myan_bound4144) +
  tm_fill("total_inci",
          n = 10,
          style = "quantile",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Distribution of Armed Conflicts in Myanmar \nQuantile classification",
            title = "(2010-2023)",
            main.title.size = 0.7,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


class_kmeans <- tm_shape(myan_bound4144) +
  tm_fill("total_inci",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Distribution of Armed Conflicts in Myanmar \nKmeans classification",
            title = "(2010-2023)",
            main.title.size = 0.7,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))
Show code
tmap_arrange(class_equal, class_pretty, class_quant, class_kmeans, asp=1, ncol=4) 

Spatial Distribution of Political Violence (2010 to 2023)

kmeans Classification

Show code
pv10 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2010",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2010",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv11 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2011",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2011",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv12 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2012",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2012",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv13 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2013",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2013",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv14 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2014",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2014",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv15 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2015",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2015",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv16 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2016",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2016",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv17 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2017",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2017",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv18 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2018",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2018",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv19 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2019",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2019",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv20 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2020",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2020",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv21 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2021",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2021",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv22 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2022",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2022",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


pv23 <- tm_shape(mapping_rates) +
  tm_fill("pct_politicalrate_2023",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Political Violence \nin Myanmar (kmeans Classification)",
            title = "2023",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))
Show code
tmap_arrange(pv10, pv11, pv12, pv13, pv14, pv15, pv16, 
             pv17, pv18, pv19, pv20, pv21, pv22, pv23, 
             asp = 1,
             ncol=7, nrow=2)

Spatial Distribution of Violence Against Civilians (2010 to 2023)

kmeans Classification

Show code
cv10 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2010",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2010",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv11 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2011",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2011",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv12 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2012",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2012",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv13 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2013",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2013",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv14 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2014",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2014",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv15 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2015",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2015",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv16 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2016",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2016",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv17 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2017",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2017",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv18 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2018",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2018",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv19 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2019",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2019",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv20 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2020",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2020",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv21 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2021",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2021",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv22 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2022",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2022",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


cv23 <- tm_shape(mapping_rates) +
  tm_fill("pct_civilianrate_2023",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Violence against Civilians \nin Myanmar (kmeans Classification)",
            title = "2023",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))
Show code
tmap_arrange(cv10, cv11, cv12, cv13, cv14, cv15, cv16, 
             cv17, cv18, cv19, cv20, cv21, cv22, cv23, 
             asp = 1,
             ncol=7, nrow=2)

Spatial Distribution of Government Regaining Territory (2010 to 2023)

equal Classification

Show code
gr10 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2010",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2010",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

gr11 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2011",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2011",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr12 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2012",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2012",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr13 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2013",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2013",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr14 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2014",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2014",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr15 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2015",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2015",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr16 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2016",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2016",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr17 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2017",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2017",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr18 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2018",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2018",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr19 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2019",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2019",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr20 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2020",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2020",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr21 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2021",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2021",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr22 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2022",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2022",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


gr23 <- tm_shape(mapping_rates) +
  tm_fill("pct_govtregain_2023",
          n = 10,
          style = "equal",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Government Regaining \nin Myanmar (equal Classification)",
            title = "2023",
            main.title.size = 0.8,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

2015 & 2017

Show code
tmap_arrange(gr15, gr17, asp = 1,
             ncol=2, nrow=1)

Spatial Distribution of Non-state Overtaking Territory (2010 to 2023)

to remove??? pretty Classification

Show code
nse10 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2010",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2010",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

nse11 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2011",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2011",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse12 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2012",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2012",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse13 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2013",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2013",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse14 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2014",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2014",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse15 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2015",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2015",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse16 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2016",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2016",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse17 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2017",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2017",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse18 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2018",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2018",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse19 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2019",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2019",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse20 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2020",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2020",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse21 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2021",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2021",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse22 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2022",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2022",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


nse23 <- tm_shape(mapping_rates) +
  tm_fill("pct_nonstateex_2023",
          n = 10,
          style = "pretty",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Non-state Overtaking \nin Myanmar (equal Classification)",
            title = "2023",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

Spatial Distribution of Fatalities (2010 to 2023)

kmeans Classification

Show code
f10 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2010",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2010",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f11 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2011",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2011",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f12 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2012",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2012",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f13 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2013",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2013",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f14 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2014",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2014",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f15 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2015",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2015",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f16 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2016",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2016",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f17 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2017",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2017",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f18 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2018",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2018",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f19 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2019",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2019",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f20 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2020",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2020",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f21 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2021",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2015",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f22 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2022",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2022",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))


f23 <- tm_shape(mapping_rates) +
  tm_fill("pct_fata_2023",
          n = 10,
          style = "kmeans",
          palette = "Reds",
          legend.hist = TRUE, 
          legend.is.portrait = TRUE,
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1,
             alpha = 1) +
  tm_layout(main.title = "Spatial Distribution of Fatalities \nin Myanmar (kmeans Classification)",
            title = "2023",
            main.title.size = 0.55,
            legend.height = 0.60, 
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))
Show code
tmap_arrange(f10, f11, f12, f13, f14, f15, f16, 
             f17, f18, f19, f20, f21, f22, f23, 
             asp = 1,
             ncol=7, nrow=2)

Interactive Choropleth Map

Show code
tmap_obj <- tm_shape(mapping_rates) +
  tm_fill("total_inci", 
          n = 10, 
          style = "kmeans", 
          palette = "Reds", 
          legend.hist = TRUE, 
          legend.is.portrait = TRUE, 
          legend.hist.z = 0.1) +
  tm_borders(lwd = 0.1, alpha = 1) +
  tm_layout(main.title = "Distribution of Armed Conflict Incidents in Myanmar \nKmeans classification",
            title = "(2010-2023)",
            main.title.size = 1,
            legend.height = 0.60,
            legend.width = 5.0,
            legend.outside = FALSE,
            legend.position = c("left", "bottom"))

leaflet_map <- tmap_leaflet(tmap_obj) %>%
  addTiles('https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png') %>%
  addPolygons(data = mapping_rates, 
              label = ~paste("Custom Tooltip Content: ", mapping_rates$total_inci, "\n", mapping_rates$total_fata))

leaflet_map

3.4 Spatial Points

Design Features - XXX
  • t

Point Symbol Map

To show the specific armed conflict events based on their geographical coordinates. Use of long and lat.

Show code
cof <- colorFactor(c("#ff7e8a", "#394938", "#ffa500", "#0092ff", "#741b47", "#60dcb5"), 
                   domain=c("Battles", "Explosions/ Remote violence", "Protests", "Riots",
                            "Strategic developments", "Violence against civilians"))

incident_pts <- final %>%
  filter(fatalities > 0)
psmap <-  leaflet() %>% 
  addTiles('https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png') %>%
  setView(100, 20, zoom = 5) %>%
  addCircles(data=incident_pts, lat= ~latitude, lng = ~longitude, color = ~cof(event_type), 
             fillColor = "black",
             popup = paste( "<strong>", incident_pts$event_date, "</strong>", 
                            "<br><strong>Country: </strong>",
                            incident_pts$country, 
                            "<br><strong>Sub-national Admin Region: </strong>",
                            incident_pts$admin1, "/", 
                            incident_pts$admin2, "/", 
                            incident_pts$admin3, 
                            "<br><strong>Event type: </strong>",
                            incident_pts$event_type, 
                            "<br><strong>Sub-event type: </strong>", 
                            incident_pts$sub_event_type, 
                            "<br><strong>Summary: </strong>", 
                            incident_pts$notes,
                            "<br><strong>Total Fatalities: </strong>",
                            incident_pts$fatalities)) %>%
  addLegend("bottomright", colors = c("#ff7e8a", "#394938", "#ffa500", "#0092ff", "#741b47", "#60dcb5"), 
            labels = c("Battles", "Explosions/ Remote violence", "Protests", "Riots",
                            "Strategic developments", "Violence against civilians"), title="Event Type") 
 
psmap

3.5 Spatial Concentration/ Intensity

Design Features - XXX
  • t

Use Hotspot map

never use: https://trucvietle.me/r/tutorial/2017/01/18/spatial-heat-map-plotting-using-r.html

https://www.supplychaindataanalytics.com/leaflet-heatmaps-in-r/

Show code
incident_pts <- final %>%
  filter(fatalities > 0)
# create fatalities hotspot intensity
hotmap_fata <-  leaflet() %>% 
  addTiles('https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png') %>%
  setView(100, 20, zoom = 5) %>%
  addHeatmap(data=incident_pts, lng = ~longitude, lat = ~latitude, intensity = ~total_fata, max = 100, radius = 10, blur = 10)


incident_pts <- final %>%
  filter(fatalities > 0)
# create armed conflict incidents hotspot intensity
hotmap_inci <-  leaflet() %>% 
  addTiles('https://basemaps.cartocdn.com/light_all/{z}/{x}/{y}.png') %>%
  setView(100, 20, zoom = 5) %>%
  addHeatmap(data=incident_pts, lng = ~longitude, lat = ~latitude, intensity = ~total_inci, max = 100, radius = 10, blur = 10) %>%
  addPopups(data = incident_pts, lng = ~longitude, lat = ~latitude,
            popup = ~paste("<strong>Date: </strong>", event_date, "<br><strong>Country: </strong>", country))

# latticeview(hotmap_fata, hotmap_inci)
hotmap_fata
# switch tmap off
tmap_mode("plot")

Reference

Back to top